Robo Roach Part 2
Output Devices Project
Overview
My plan is to design my lego display as a slot car version of a miniature Monaco. For next week's assignment, I plan on working on finishing up the CAD of the slot track and machining it, making the first big step in my final project.
For this week's Input Devices assignment, I started building a small photophobic robot cockroach called RoboRoach. The idea came from my 6.200 Circuits & Electronics class, where we built a purely analog light-following robot using photoresistors. I thought it would be fun to flip the behavior and make something that runs away from light instead, just like a real cockroach. I experimented with photosensors, op-amps, and potentiometers to create adjustable voltage offsets and amplify tiny light-dependent changes. This week was all about learning how to treat these components as input devices and measuring the voltages they produce. I will build on this project during next week's assignment to complete my photophobic RoboRoachBoard Design
For RoboRoach, my goal is to turn light intensity into an analog signal that becomes more negative as the robot is exposed to brighter light to mimick a cockroach trying to escape illumination. To do this, I used a photoresistor as a light sensor, an op-amp amplifier, and a potentiometer to create an offset voltage. The photoresistor is placed in a voltage divider so that its resistance (which drops under bright light) produces a corresponding change in voltage. That raw signal is very small, so I added an op-amp gain stage to amplify the voltage from the light sensor into something the system can actually react to. Because I want the final output to be able to go below ground—more negative as the light increases—I used a potentiometer to create an adjustable offset voltage. This shifts the entire signal downward so that the op-amp output isn’t restricted to only positive values. With the offset, dim light sits near zero, and bright light pushes the output increasingly negative. The final output from the op-amp goes straight into the control section of the robot (no comparator). The hand-drawn schematic below shows the main blocks of the circuit: the photoresistor sensing divider, the gain stage, and the offset network that allows the output to slide into the negative range under bright light.
I created the schematic and layout in KiCad that I used for milling and assembly.
Schematic
Layout
Here's a prototype that I put together on a breadboard to make sure everything works as expected before milling and soldering.
Milling
For milling this board, I followed the exact same workflow as in my Electronics Production week.
I reused the same design rules and trace widths from my previous boards, exported the traces and outline as PNGs, and ran them through Mods on the Roland mill.
I used a 1/64" bit for traces and a 1/32" bit for the outline.
Once the board finished milling, I did a quick pre-solder continuity check using the multimeter in continuity mode just to make sure there were no accidental shorts from the mill.
- Touch the probes to two traces that should NOT be connected → it should NOT beep.
- Touch two ends of the same trace that should be connected → it should beep.
This catches milling shorts, broken traces and copper that didn't fully mill away
Soldering
I similarly followed the soldering workflow from my Electronics Production week. For this board, I mainly had to place the op-amp, the potentiometer, and a few resistors for the divider and offset network. I started with the op-amp by tinning one pad, placing the chip with tweezers, and reflowing that pin to hold it down. After that, I soldered the rest of the pins and then added the resistors and potentiometer. Nothing on this board was especially tricky, so I mostly just followed the usual steps and soldered everything in place. After assembling the board, I used a multimeter in continuity mode to check that I didn't accidentally bridge any pins and that each part was actually connected to its trace. Once that was done, the board was ready for testing.
Testing
To test this board, I programmed an ESP32-C3 in the Arduino IDE and used it to read the two op-amp outputs.
Each amplified photoresistor signal was connected to one of the MCU's ADC pins, and I printed the readings to the serial monitor while I adjusted the lighting.
Shining a flashlight on either sensor or covering it confirmed that both channels responded correctly and independently to changes in light intensity.
Once I confirmed that the MCU was receiving clean sensor values, I wrote a simple version of the RoboRoach's behavioral logic.
Based on which side was brighter, the code decided whether the robot should “go left,” “go right,” or “back up.”
Instead of driving actual motors at this stage, I routed the two “motor output” pins from the ESP32-C3 to an oscilloscope.
Watching the oscilloscope traces allowed me to see the exact voltage changes the MCU was producing in response to different lighting conditions.
When I illuminated one sensor, I could clearly see the corresponding output pin switch to the “turn away” signal; when both sensors got bright, the output for “back up” activated instead.
This confirmed that the logic, the sensing, and the control outputs all aligned.